import request from '../utils/request.js'

/**
 * 获取设备类型的信息
 * @param {
 *  query_param,
 *  category,
 *  vendor
 * } query
 * @returns
 */
export function getSensorInitInfo(params) {
    return request({
        url: '/device-mang/devices/types/',
        method: 'get',
        params
    })
}
/**
 * 获取表格数据
 * @param {
 *   page,
 *   page_size,
 *   ordering
 * } query
 * @returns
 */
export function getSensorList(query) {
    return request({
        url: '/device-mang/devices/adv/list/',
        method: 'get',
        params: query
    })
}

/**
 * 增加设备
 * @param {
 *   alias_name,
 *   sn,
 *   type_id
 * } query
 * @returns
 */
export function createSensor(data) {
    return request({
        url: '/device-mang/devices/adv/',
        method: 'post',
        data
    })
}
/**
 * 编辑设备
 * @param {
 *   alias_name,
 *   sn,
 *   type_id
 * } query
 * @returns
 */
export function updateSensor(id, data) {
    return request({
        url: `/device-mang/devices/adv/${id}/`,
        method: 'patch',
        data
    })
}
/**
 * 删除设备
 * @param {
 *   id
 * } query
 * @returns
 */
export function deleteSensor(id) {
    return request({
        url: `/device-mang/devices/adv/${id}/`,
        method: 'delete'
    })
}
/**
 * 获取设备详情
 * @param { id } query
 * @returns
 */
export function getSensorDetail(query) {
    return request({
        url: '/device-mang/devices/adv/',
        method: 'get',
        params: query
    })
}

/**
 * 批量导出设备高级的列表信息
 * @param { id } query
 * @returns
 */
export function exportDevicesList(params) {
    return request({
        url: '/device-mang/devices/adv/batch/',
        method: 'get',
        params
    })
}

/**
 * 批量导入设备高级的列表信息
 * @param {
 *   alias_name,
 *   sn,
 *   dev_code,
 *   category,
 *   vendor,
 *   model,
 * } query
 * @returns
 */
export function importDevicesList(data) {
    return request({
        url: '/device-mang/devices/adv/batch/',
        method: 'post',
        data
    })
}